package com.scpii.universal.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.scpii.universal.hibernate.dao.BaseDao;
import com.scpii.universal.hibernate.entity.ContentImgTab;
import com.scpii.universal.hibernate.intface.BaseInterface;
import com.scpii.universal.util.SpringBeanFactory;

public class ContentImgTabService implements BaseInterface<ContentImgTab> {
	private static final Logger log = LoggerFactory
			.getLogger(ContentImgTabService.class);
//	private BaseDao<ContentImgTab> contentImgTabDao = SpringBeanFactory.contentImgTabDao;
	private BaseDao<ContentImgTab> contentImgTabDao;
	
	public ContentImgTab get(Integer id) throws Exception {
		return contentImgTabDao.get(id);
	}

	public List<ContentImgTab> getAll() throws Exception {
		return contentImgTabDao.getAll();
	}

	public ContentImgTab get(String propertyName, Object value)
			throws Exception {
		return null;
	}

	public List<ContentImgTab> getList(String propertyName, Object value)
			throws Exception {
		return null;
	}

	public Long getTotalCount() throws Exception {
		return null;
	}

	public void save(ContentImgTab obj) throws Exception {

	}

	public void update(ContentImgTab obj) throws Exception {

	}

	public void delete(ContentImgTab obj) throws Exception {

	}

	public void delete(Integer id) throws Exception {

	}

	public List<ContentImgTab> hqlGetList(String hql,
			Map<String, Object> argsMap) throws Exception {
		return contentImgTabDao.hqlGetList(hql, argsMap);
	}

	public void hqlUpdate(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		contentImgTabDao.hqlUpdate(namedHqlQuery, argsMap);
	}

	public Long hqlGetNums(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		return contentImgTabDao.hqlGetNums(namedHqlQuery, argsMap);
	}

	public List<ContentImgTab> sqlGetList(String sqls,
			Map<String, Object> argsMap) throws Exception {
		return contentImgTabDao.sqlGetList(sqls, argsMap);
	}

	public void sqlUpdate(String sqls, Map<String, Object> argsMap)
			throws Exception {
		contentImgTabDao.sqlUpdate(sqls, argsMap);
	}

	public Long sqlGetNum(String sqls, Map<String, Object> argsMap)
			throws Exception {
		return contentImgTabDao.sqlGetNum(sqls, argsMap);
	}

	/**
	 * 根据内容ID，获得与内容相关的图片列表
	 * 
	 * @param contentId
	 * @param type 
	 * 			作用类型0详情页展示，1相册用
	 * @return
	 * @throws Exception
	 * @author 甘建新 2012-7-17上午01:13:07
	 */
	public List<ContentImgTab> getImgListByContentId(int contentId, int type)
			throws Exception {
		if (contentId>0) {
			List<ContentImgTab> imgList = new ArrayList<ContentImgTab>();
			//设置参数键值对
			Map<String, Object> argsMap = new HashMap<String, Object>();
			argsMap.put("contentId", contentId);
			argsMap.put("intType", type);
			//通过HQL查询数据库
			imgList = this.hqlGetList("GET_IMGS_BY_CONTENTID", argsMap);
			return imgList;
		}
		return null;
	}
	
	public List<ContentImgTab> getResourceByContentId(int contentId, int type)
			throws Exception {
		if (contentId > 0) {
			List<ContentImgTab> imgList = new ArrayList<ContentImgTab>();
			// 设置参数键值对
			Map<String, Object> argsMap = new HashMap<String, Object>();
			argsMap.put("contentId", contentId);
			argsMap.put("intType", type);
			// 通过HQL查询数据库
			imgList = this.hqlGetList("GET_RESOURCE_BY_CONTENTID", argsMap);
			return imgList;
		}
		return null;
	}
	//Setter

	public void setContentImgTabDao(BaseDao<ContentImgTab> contentImgTabDao) {
		this.contentImgTabDao = contentImgTabDao;
	}
	
}